<?php


namespace app\common;

class AppAgent
{
	public static function money($agent, $number, $type, $remarks)
	{
		$data = ["uid" => $agent["id"], "number" => $number, "type" => $type, "remarks" => $remarks, "after" => $type ? $agent["money"] - $number : $agent["money"] + $number, "ago" => $agent["money"], "time" => time()];
		$up = \think\Db::name("app_agent")->where(["id" => $agent["id"]]);
		if ($type == 0) {
			$up->setInc("money", $number);
		} else {
			$up->setDec("money", $number);
		}
		return \think\Db::name("app_agent_money_log")->insertGetId($data);
	}
}